/*
 * @Author: your name
 * @Date: 2021-07-09 11:01:41
 * @LastEditTime: 2021-07-09 11:18:39
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: /www/dtk_static_public_js/public/dtk-nodejs-api-sdk/server.js
 */
var http = require('http');
var dtkSdk = require('./dist/index.js');
const sdk = new dtkSdk({appKey:'5d9d5942f3293',appSecret:'3506ac9e3a2ca29ecdcebd74ad25560b',checkSign:2});

http.createServer(async function (request, response) {
    /*
    *  @checkSign: 1 默认老版本验签  2 新版验签
    *  @appKey: 用户填写 appkey
    *  @appSecret: 用户填写 appSecret
    */ 
    

    const res = await sdk.request('https://openapi.haojiequ.com/api/tb-service/get-brand-list',{
      form:{pageId:'1',pageSize:20,version:'v1.1.0'}
    });
    console.log(res);

    // 发送 HTTP 头部 
    // HTTP 状态值: 200 : OK
    // 内容类型: text/plain
    response.writeHead(200, {'Content-Type': 'text/plain'});

    // 发送响应数据 "Hello World"
    response.end(`loading:`);
}).listen(8888);
